package app.kotlin_1.adapter
import android.content.Context
import android.view.View
import app.kotlin_1.base.BaseRecyclerViewAdapter
import app.kotlin_1.base.BaseViewHolder
import app.kotlin_1.bean.KindBean
import  kotlinx.android.synthetic.main.item_my_kind.view.*

/**
 * Created by 刘智强 on 2017/10/11.
 */
class MyKindAdapter : BaseRecyclerViewAdapter<KindBean> {
    private var context: Context? = null
    private var datas = mutableListOf<KindBean>()

    constructor(context: Context?, datas: MutableList<KindBean>, layoutId: Int?) : super(context, datas, layoutId)

    override fun bindData(viewHolder: BaseViewHolder, data: KindBean, position: Int) {
        if (data.isTip) rootView?.ivTip?.visibility = View.VISIBLE else rootView?.ivTip?.visibility = View.GONE
        if (data.num == 0) {
            rootView?.tvTips?.visibility = View.GONE
        } else {
            rootView?.tvTips?.visibility = View.VISIBLE
            rootView?.tvTips?.text = data.num.toString()
        }
        rootView?.ivIcon?.setImageResource(data.icon!!)
        rootView?.tvName?.text = data.title


    }
}